<template>
  <div class="card-box">
    <el-form
      :model="formData"
      ref="formRef"
      :rules="fromRules"
      label-width="160px"
      class="form__content"
    >
      <div class="divider">基本信息:</div>
      <el-row>
        <el-col :span="8" v-if="route?.query?.contractId">
          <el-form-item label="检查名称" prop="inspectName">
            <el-input v-model="formData.inspectName" disabled></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="项目名称" prop="projectName">
            <el-select
              v-model="currentProject.projectName"
              clearable
              placeholder="请选择"
            >
              <el-option :value="projectList">
                <el-tree
                  id="tree-option"
                  :data="projectList"
                  accordion
                  node-key="id"
                  ref="projectTreeRef"
                  highlight-current
                  :props="defaultProps"
                  @check-change="handleCheckChange"
                  check-on-click-node
                  :expand-on-click-node="false"
                >
                </el-tree>
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="合同名称" prop="contractId">
            <el-select
              class="width-custom"
              v-model="formData.contractId"
              ref="contractRef"
              @change="handleChangeContract"
            >
              <!-- value-key="contractId" -->
              <el-option
                class="default-option"
                v-for="item in contracList"
                :key="item.contractId"
                :label="item.contractName"
                :value="item.contractId"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <el-form-item label="单体(子项)工程名称" prop="subProjectCode">
            <el-input v-model="formData.subProjectCode"></el-input>
          </el-form-item>
        </el-col>
        <!-- <el-col :span="8">
          <el-form-item label="分部名称" prop="segmentCode">
            <el-input v-model="formData.segmentCode"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="子分部名称" prop="subSegmentCode">
            <el-input v-model="formData.subSegmentCode"></el-input>
          </el-form-item>
        </el-col> -->
      </el-row>
      <!-- <div class="divider">检查标准:</div> -->
      <el-row>
        <el-col :span="8">
          <el-form-item label="模块" prop="inspectClassCode">
            <el-select
              class="width-custom"
              v-model="formData.inspectClassCode"
              @change="handleCheckInspectOne"
              value-key="id"
            >
              <el-option
                class="default-option"
                v-for="item in checkListOne"
                :key="item.id"
                :label="item.itemText"
                :value="item"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="分部" prop="inspectSubClassCode">
            <el-select
              class="width-custom"
              v-model="formData.inspectSubClassCode"
              @change="handleCheckInspectTwo"
              value-key="id"
            >
              <el-option
                class="default-option"
                v-for="item in checkListTwo"
                :key="item.id"
                :label="item.itemText"
                :value="item"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <!-- <div class="divider">检查项:</div> -->
      <el-row>
        <el-col :span="8">
          <el-form-item label="子分部" prop="inspectItemCode">
            <el-select
              class="width-custom"
              v-model="formData.inspectItemCode"
              @change="handleCheckInspectThree"
              value-key="id"
            >
              <el-option
                class="default-option"
                v-for="item in checkListThree"
                :key="item.id"
                :label="item.itemText"
                :value="item"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="分项" prop="inspectSubItemCode">
            <el-select
              class="width-custom"
              v-model="formData.inspectSubItemCode"
              @change="handleCheckInspectFour"
              value-key="id"
            >
              <el-option
                class="default-option"
                v-for="item in checkListFour"
                :key="item.id"
                :label="item.itemText"
                :value="item"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <!-- <div class="divider">检查安排:</div> -->
      <el-row>
        <el-col :span="8">
          <el-form-item label="检查人">
            <el-input disabled v-model="currentName"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="检查类型" prop="inspectTypeCode">
            <el-select
              disabled
              class="width-custom"
              v-model="formData.inspectTypeCode"
              value-key="inspectTypeCode"
            >
              <el-option
                class="default-option"
                v-for="item in inspectTypeList"
                :key="item.inspectTypeCode"
                :label="item.inspectTypeName"
                :value="item"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <!-- <el-col :span="8">
          <el-form-item label="检查截止时间" prop="inspectionDeadline">
            <el-date-picker
              v-model="formData.inspectionDeadline"
              type="datetime"
              value-format="YYYY-MM-DD HH:mm:ss"
              placeholder="选择日期"
              :disabledDate="disabledDate"
            ></el-date-picker>
          </el-form-item>
        </el-col> -->
      </el-row>
      <div class="divider"><span>*</span>检查内容:</div>
      <el-table
        :data="tableContentList"
        :span-method="objectSpanMethod"
        border
        @selection-change="handleSelectionChange"
        :row-key="getRowKeys"
        ref="tableRef"
      >
        <el-table-column
          type="selection"
          :reserve-selection="true"
          width="55"
        />
        <!-- <el-table-column label="序号" type="index" width="50"></el-table-column> -->
        <!-- <el-table-column prop="id" label="ID" width="180"></el-table-column> -->
        <el-table-column prop="content" label="检查内容"></el-table-column>
        <el-table-column prop="requests" label="标准要求"></el-table-column>
        <el-table-column prop="insMethod" label="检查方法"> </el-table-column>
        <el-table-column prop="" label="检查小结"> </el-table-column>
        <el-table-column prop="" label="是否合格" width="180">
          <template #default>
            <el-radio-group>
              <el-radio :label="0">合格</el-radio>
              <el-radio :label="1">不合格</el-radio>
            </el-radio-group>
          </template>
        </el-table-column>
        <el-table-column prop="" label="附件"></el-table-column>
      </el-table>
    </el-form>
    <div class="form__footer">
      <el-button type="primary" @click="handleSave">保 存</el-button>
      <el-button type="primary" @click="handleSubmit">提 交</el-button>
    </div>

    <el-dialog
      title="创建检查任务"
      v-model="commitVisible"
      destroy-on-close
      width="600px"
    >
      <div class="dialog__content">
        <!-- <div class="dialog__content--title">任务基本信息:</div> -->
        <div style="width: 100%; text-align: center; padding: 20px 0">
          是否确定提交？
        </div>
      </div>

      <template #footer>
        <span class="dialog-footer">
          <el-button @click="commitVisible = false">取消</el-button>
          <!-- <el-button type="primary" @click="handleRequest">确认</el-button> -->
          <ReButton type="primary" debounce auto-loading @click="handleRequest"
            >确认</ReButton
          >
        </span>
      </template>
    </el-dialog>
  </div>
</template>

<script lang="ts" setup>
import {
  reactive,
  ref,
  defineProps,
  watch,
  unref,
  nextTick,
  onMounted
} from "vue";
import { useRouter, useRoute } from "vue-router";
import { storageLocal } from "/@/utils/storage";
import { hasRoleCode } from "/@/utils/hasRoleCode";
import { groupBy, flattenDeep } from "lodash-es";

import {
  postProjectTree,
  postGetContractList,
  getContractDetail,
  getProTeamMembers
} from "/@/api/acceptance";

import {
  postQtyCheckStart,
  postStorageFlowStart,
  dropDownList,
  checkContentList
} from "/@/api/quality";
import NotifMessage from "/@/utils/message/notification";
// import { ElMessageBox } from "element-plus";
// import { download } from "/@/utils/download";
// import { hasRoleCode } from "/@/utils/hasRoleCode";
import ReButton from "/@/components/ReButton/index.vue";

const router = useRouter();
const route = useRoute();
let commitVisible = ref<boolean>(false);
const formRef = ref<HTMLFormElement | null>(null) as any;
const tableRef = ref<HTMLTableElement | null>(null) as any;
const contractRef = ref<HTMLElement | null>(null) as any;
const projectTreeRef = ref<HTMLElement | null>(null) as any;
let projectList = ref([]);
let contracList = ref([]);
let currentProject = reactive({
  projectName: "",
  projectManageId: ""
});
let projectTeam = ref([]);
let currentName = ref("");
// let currentTeam = reactive({
//   userName: "",
//   userId: ""
// }); // 下一节点的处理人信息
const props = defineProps({
  storageData: {
    type: Object,
    default: () => {}
  }
});

let spanArr = ref([]); // 用于存放每一行记录的合并数
let pos = ref(null); // 用于存放每一行记录的合并数

const getRowKeys = row => {
  return row.checkItemId;
};

// const disabledDate = time => {
//   return time.getTime() < Date.now() - 8.64e7; //如果没有后面的-8.64e7就是不可以选择今天的
// };

let formData = reactive({
  inspectName: "",
  projectName: "",
  projectManageId: "",
  contractName: null,
  contractId: null,
  contractNum: "",
  insContentList: [],
  inspectClassCode: null,
  inspectClassName: "",
  inspectSubClassCode: null,
  inspectSubClassName: "",
  inspectItemCode: null,
  inspectItemName: "",
  inspectSubItemCode: null,
  inspectSubItemName: "",

  inspectTypeCode: { inspectTypeCode: 1, inspectTypeName: "日常检查" },
  inspectTypeName: "",

  inspectionDeadline: "",

  inspectorId: "",
  inspectorName: "",

  recFeedback: "",
  recOpinions: "",
  remarks: "",
  segmentCode: "",
  segmentName: "",
  subProjectCode: "",
  subProjectName: "",
  subSegmentCode: "",
  subSegmentName: ""
});

let checkListOne = ref([]);
let checkListTwo = ref([]);
let checkListThree = ref([]);
let checkListFour = ref([]);
let tableContentList = ref([]);
let inspectTypeList = ref([
  { inspectTypeCode: 1, inspectTypeName: "日常检查" }
]);

const fromRules = {
  inspectName: [
    { required: true, message: "请输入检查名称", trigger: "change" }
  ],
  // billNum: "",
  projectName: [{ required: true, message: "请选择项目", trigger: "change" }],
  contractId: [{ required: true, message: "请选择合同", trigger: "change" }],
  subProjectCode: [
    { required: true, message: "请填写单体工程名称", trigger: "blur" }
  ],
  inspectClassCode: [
    { required: true, message: "请选择模块", trigger: "change" }
  ],
  inspectSubClassCode: [
    { required: true, message: "请选择分部", trigger: "change" }
  ],
  inspectItemCode: [
    { required: true, message: "请选择子分部", trigger: "change" }
  ],
  inspectSubItemCode: [
    { required: true, message: "请选择分项", trigger: "change" }
  ],
  inspectTypeCode: [
    { required: true, message: "请选择检查类型", trigger: "change" }
  ],
  inspectionDeadline: [
    { required: true, message: "请选择检查截止时间", trigger: "change" }
  ],
  insContentList: [
    { required: true, message: "请选择检查内容", trigger: "change" }
  ]
};

const defaultProps = {
  children: "children",
  label: "projectName",
  id: "id"
};

// 获取项目信息
const getProjectList = async () => {
  try {
    const { code, data } = await postProjectTree({});
    if (code === 200) {
      projectList.value = data;
    }
  } catch (err) {
    console.log(err);
  }
};

// 获取合同信息
const getContractList = async () => {
  try {
    const params = {
      projectPathLike: currentProject.projectManageId
    };
    const { code, data } = await postGetContractList(params);
    if (code === 200) {
      contracList.value = data;
    }
  } catch (err) {
    console.log(err);
  }
};

const handleCheckChange = () => {
  const res = projectTreeRef.value.getCurrentNode();
  currentProject.projectName = [res][0].projectName;
  currentProject.projectManageId = [res][0].id;
  handleClearFormData();
};

const handleClearFormData = () => {
  formData.contractId = "";
  formData.contractNum = "";
  formData.projectManageId = "";
};

const handleChangeContract = async () => {
  if (formData.contractId) {
    const params = {
      id: formData.contractId
    };
    const { code, data } = await getContractDetail(params);
    if (code === 200 && data) {
      const { contractNum, projectManageId, projectName, contractName } = data;
      formData.contractNum = contractNum;
      formData.contractName = contractName;
      formData.projectManageId = projectManageId;
      formData.projectName = projectName;
      currentProject.projectName = formData.projectName;
      currentProject.projectManageId = formData.projectManageId;
    }
  } else {
    handleClearFormData();
  }
};

watch(
  () => props.storageData,
  newVal => {
    setTimeout(() => {
      if (newVal.inspectName) {
        console.log(newVal, "newVal");
        formData.inspectName = newVal.inspectName;
        formData.projectName = newVal.projectName;
        formData.projectManageId = newVal.projectManageId;
        formData.contractName = newVal.contractName;
        formData.contractId = newVal.contractId;
        formData.contractNum = newVal.contractNum;
        formData.remarks = newVal.remarks;
        currentProject.projectName = formData.projectName;
        currentProject.projectManageId = formData.projectManageId;
        // ---------------
        // formData.insContentList = newVal.insContentList;
        formData.insContentList = newVal.checkContentList;
        formData.inspectClassCode = {
          id: +newVal.inspectClassCode,
          itemText: newVal.inspectClassName
        };
        formData.inspectClassName = newVal.inspectClassName;

        formData.inspectSubClassCode = {
          id: +newVal.inspectSubClassCode,
          itemText: newVal.inspectSubClassName
        };
        formData.inspectSubClassName = newVal.inspectSubClassName;

        formData.inspectItemCode = {
          id: +newVal.inspectItemCode,
          itemText: newVal.inspectItemName
        };
        formData.inspectItemName = newVal.inspectItemName;

        formData.inspectSubItemCode = {
          id: +newVal.inspectSubItemCode,
          itemText: newVal.inspectSubItemName
        };
        formData.inspectSubItemName = newVal.inspectSubItemName;

        formData.inspectTypeCode = {
          inspectTypeCode: +newVal.inspectTypeCode,
          inspectTypeName: newVal.inspectTypeName
        };
        formData.inspectTypeName = newVal.inspectTypeName;

        formData.inspectionDeadline = newVal.inspectionDeadline;

        formData.inspectorId = newVal.inspectorId;
        formData.inspectorName = newVal.inspectorName;
        formData.recFeedback = newVal.recFeedback;
        formData.recOpinions = newVal.recOpinions;

        formData.segmentCode = newVal.segmentCode;
        formData.segmentName = newVal.segmentName;
        formData.subProjectCode = newVal.subProjectCode;
        formData.subProjectName = newVal.subProjectName;
        formData.subSegmentCode = newVal.subSegmentCode;
        formData.subSegmentName = newVal.subSegmentName;

        // 获取table 内容

        setTimeout(() => {
          nextTick(() => {
            handleCheckInspectFour(formData.inspectSubItemCode);
            newVal.checkContentList.length &&
              newVal.checkContentList.forEach(row => {
                tableRef.value.toggleRowSelection(row);
              });
          });
        }, 500);
      }
    }, 500);
  },
  {
    deep: true,
    immediate: true
  }
);

onMounted(() => {
  currentName.value = storageLocal.getItem("info").name;
});

watch(
  () => currentProject,
  newVal => {
    if (newVal) {
      formData.projectName = newVal.projectName;
      getContractList();
    }
  },
  {
    deep: true
  }
);

watch(
  () => formData.inspectClassCode,
  async newVal => {
    if (newVal) {
      const { id } = newVal;
      const { code, data } = await dropDownList({
        parentId: id,
        pageNum: 1,
        pageSize: 0
      });
      if (code === 200) {
        checkListTwo.value = data;

        formData.insContentList = [];
        tableContentList.value = [];
      }
    } else {
      formData.inspectSubClassCode = null;
      formData.inspectItemCode = null;
      formData.inspectSubItemCode = null;
      checkListTwo.value = [];
      checkListThree.value = [];
      checkListFour.value = [];
    }
  },
  {
    deep: true
  }
);

watch(
  () => formData.inspectSubClassCode,
  async newVal => {
    if (newVal) {
      const { id } = newVal;
      const { code, data } = await dropDownList({
        parentId: id,
        pageNum: 1,
        pageSize: 0
      });
      if (code === 200) {
        checkListThree.value = data;

        formData.insContentList = [];
        tableContentList.value = [];
      }
    } else {
      checkListThree.value = [];
      checkListFour.value = [];
      formData.inspectItemCode = null;
      formData.inspectSubItemCode = null;
    }
  },
  {
    deep: true
  }
);

watch(
  () => formData.inspectItemCode,
  async newVal => {
    if (newVal) {
      const { id } = newVal;
      const { code, data } = await dropDownList({
        parentId: id,
        pageNum: 1,
        pageSize: 0
      });
      if (code === 200) {
        checkListFour.value = data;
        formData.insContentList = [];
        tableContentList.value = [];
      }
    } else {
      checkListFour.value = [];
      formData.inspectSubItemCode = null;
    }
  },
  {
    deep: true
  }
);
const handleCheckInspectOne = () => {
  formData.inspectSubClassCode = null;
  formData.inspectItemCode = null;
  formData.inspectSubItemCode = null;
};

const handleCheckInspectTwo = () => {
  formData.inspectItemCode = null;
  formData.inspectSubItemCode = null;
};

const handleCheckInspectThree = () => {
  formData.inspectSubItemCode = null;
};

const handleCheckInspectFour = async item => {
  spanArr.value = [];
  pos.value = null;
  const { id, itemText } = item;
  formData.inspectName = `${itemText}检查`;
  const params = {
    checkTypeId: id,
    pageNum: 1,
    pageSize: 0
    // checkTypeId: 274
  };
  const { code, data } = await checkContentList(params);

  if (code === 200) {
    tableContentList.value = data.map(i => {
      return {
        checkItemId: i.id,
        content: i.content,
        insMethod: i.checkMethod || "",
        insSummary: "",
        isQualifiedCheck: "",
        isQualifiedRec: "",
        recFeedbackDesc: "",
        recOpinions: "",
        remarks: "",
        requests: i.requests
      };
    });
  }
  getSpanArr(tableContentList.value);
};

// 获取检查项
const getDropDownList = async (obj: object) => {
  const { code, data } = await dropDownList(obj);
  if (code === 200) {
    checkListOne.value = data;
  }
};

const handleSubmit = async () => {
  try {
    const isValid = await new Promise(resolve =>
      formRef.value.validate(resolve)
    );

    if (!isValid) return;
    // commitVisible.value = true;

    // 获取项目组成员
    await getTeamMembers(formData.contractId);

    // 所需角色
    //  6 4 1 2 3
    console.log(projectTeam.value, "projectTeam.value");
    const isCheck = hasRoleCode(projectTeam.value, [4, 1, 3]);
    if (!isCheck) {
      NotifMessage.error("该合同未配置项目组成员，请先前往配置");
    } else {
      commitVisible.value = true;
    }
  } catch (err) {
    console.log(err);
  }
};

const handleRequest = async done => {
  try {
    // 后端要求，多次保存将传一个id过去
    const info = storageLocal.getItem("info");
    const newFormData = Object.assign(formData, {
      id: +route.query?.contractId ?? "",
      inspectorId: info?.userId,
      inspectorName: info?.name
    });

    console.log(formData, "formdata");

    const newParams = JSON.parse(
      JSON.stringify({
        ...newFormData
      })
    );

    newParams.inspectClassCode = newFormData.inspectClassCode.id;
    newParams.inspectClassName = newFormData.inspectClassCode.itemText;

    newParams.inspectSubClassCode = newFormData.inspectSubClassCode.id;
    newParams.inspectSubClassName = newFormData.inspectSubClassCode.itemText;

    newParams.inspectItemCode = newFormData.inspectItemCode.id;
    newParams.inspectItemName = newFormData.inspectItemCode.itemText;

    newParams.inspectSubItemCode = newFormData.inspectSubItemCode.id;
    newParams.inspectSubItemName = newFormData.inspectSubItemCode.itemText;

    newParams.inspectTypeCode = newFormData.inspectTypeCode.inspectTypeCode;
    newParams.inspectTypeName = newFormData.inspectTypeCode.inspectTypeName;

    newParams.insContentList = flattenDeep(
      Object.values(groupBy(newFormData.insContentList, "content"))
    );

    const params = {
      formBaseInfo: newParams,
      formSubMap: {
        flowType: 11,
        assignee: info?.userId, // 提交下一流程处理人Id
        opinion: `备注：流程发起`
      }
      // // 提交时，保存一份信息
      // tmpStorage: newParams
    };

    console.log(params, "params");
    const { code, message } = await postQtyCheckStart(params);
    if (code === 200) {
      // successMessage("到货验收发起成功");
      commitVisible.value = false;
      NotifMessage.success("提交成功");
      handleBack();
    } else {
      // errorMessage(message);
      NotifMessage.error(message);
    }
  } catch (err) {
    console.log(err);
  } finally {
    setTimeout(() => {
      done();
    }, 1000);
  }
};

const getTeamMembers = async (id: string | number) => {
  try {
    const params = {
      id
    };
    const res: any = await getProTeamMembers(params);
    if (res.code === 200) {
      projectTeam.value = res.data.memberTypeList;
    }
  } catch (err) {
    console.log(err);
  }
};

const handleSave = async () => {
  if (!formData.insContentList.length) {
    NotifMessage.error("检查内容必须选择至少一条！");
    return;
  }
  formData.projectName = currentProject.projectName;
  formData.projectManageId = currentProject.projectManageId;
  formData.insContentList = flattenDeep(
    Object.values(groupBy(formData.insContentList, "content"))
  );

  const isValid = await new Promise(resolve => formRef.value.validate(resolve));
  if (!isValid) return;
  const info = storageLocal.getItem("info");

  // 后端要求，多次保存将传一个id过去

  const newFormData = Object.assign(formData, {
    id: +route.query?.contractId ?? "",
    inspectorId: info?.userId,
    inspectorName: info?.name
  });
  const newParams = JSON.parse(
    JSON.stringify({
      ...newFormData
    })
  );

  newParams.inspectClassCode = newFormData.inspectClassCode.id;
  newParams.inspectClassName = newFormData.inspectClassCode.itemText;

  newParams.inspectSubClassCode = newFormData.inspectSubClassCode.id;
  newParams.inspectSubClassName = newFormData.inspectSubClassCode.itemText;

  newParams.inspectItemCode = newFormData.inspectItemCode.id;
  newParams.inspectItemName = newFormData.inspectItemCode.itemText;

  newParams.inspectSubItemCode = newFormData.inspectSubItemCode.id;
  newParams.inspectSubItemName = newFormData.inspectSubItemCode.itemText;

  newParams.inspectTypeCode = newFormData.inspectTypeCode.inspectTypeCode;
  newParams.inspectTypeName = newFormData.inspectTypeCode.inspectTypeName;

  const params = {
    formBaseInfo: newParams,
    formSubMap: {
      flowType: 11,
      assignee: info?.userId, // 提交下一流程处理人Id
      opinion: `备注：流程发起`
    }
    // // 提交时，保存一份信息
    // tmpStorage: newParams
  };

  try {
    const { code, message, data } = await postStorageFlowStart(params);
    if (code === 200) {
      const { fullPath, query } = unref(route);
      router.replace({
        path: "/redirect" + fullPath,
        query: Object.assign(query, { contractId: data.id })
      });
      // successMessage("到货验收发起成功");
      NotifMessage.success("保存成功");
      // router.replace("/acceptance/arrival");
    } else {
      // errorMessage(message);
      NotifMessage.error(message);
    }
  } catch (err) {
    console.log(err);
  }
};

const handleBack = () => {
  // TODO  根据来源进行处理
  if (route.query.source === "work") {
    router.push({ path: "/work/dashboard", replace: true });
  } else {
    router.push({ path: "/quality/inspection", replace: true });
  }
};

// table 处理相关--------------------------------------
const getSpanArr = data => {
  // data就是我们从后台拿到的数据
  for (let i = 0; i < data.length; i++) {
    if (i === 0) {
      spanArr.value.push(1);
      pos.value = 0;
    } else {
      // 判断当前元素与上一个元素是否相同
      if (data[i].content === data[i - 1].content) {
        spanArr.value[pos.value] += 1;
        spanArr.value.push(0);
      } else {
        spanArr.value.push(1);
        pos.value = i;
      }
    }
  }
};
const objectSpanMethod = ({ rowIndex, columnIndex }) => {
  if (columnIndex === 1) {
    const _row = spanArr.value[rowIndex];
    const _col = _row > 0 ? 1 : 0;
    return {
      // [0,0] 表示这一行不显示， [2,1]表示行的合并数
      rowspan: _row,
      colspan: _col
    };
  }
};

const handleSelectionChange = val => {
  formData.insContentList = val;
};

getProjectList();
getDropDownList({
  itemType: "A",
  pageNum: 1,
  pageSize: 0
});
</script>

<style lang="scss" scoped>
.divider {
  margin-bottom: 10px;
  // border-left: 3px solid #409eff;
  // text-indent: 8px;
  span {
    color: var(--el-color-danger);
    margin-right: 4px;
    font-size: var(--el-form-label-font-size);
  }
}
.card-box {
  width: 100%;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  .form__content {
    flex: 1;
    width: inherit;
  }
  .form__footer {
    margin-top: 20px;
    width: inherit;
    height: 40px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
  }
}

.el-select-dropdown__item {
  height: auto;
  // min-height: 100px;
  // max-height: 274px;
  padding: 0;
  overflow-x: hidden;
  overflow-y: hidden;
}
.el-select-dropdown_item.selected {
  font-weight: normal;
}

.el-select-dropdown_item.selected {
  font-weight: normal;
}

// #tree-option
#tree-option :deep .el-tree-node__content {
  height: auto;
  padding: 0 10px;
}
// #tree-option :deep .el-select-dropdown__list {
//   padding: 0 6px;
// }
#tree-option :deep .el-tree-node__label {
  font-weight: normal;
  padding: 0 10px;
  margin-right: 10px;
}

.el-tree :deep .is-current .el-tree-node__label {
  color: #409eff;
  font-weight: 700;
}
.el-tree :deep .is-current .el-tree-node__children .el-tree-node__label {
  color: #606266;
  font-weight: normal;
}
.default-option :deep .el-tree-node__label {
  font-weight: normal;
  padding: 0 10px;
  // margin-right: 10px;
}

.default-option {
  padding: 0 10px;
}

.dialog__content {
  // border: 1px solid #f0f4ff;
  // border-radius: 4px;

  &--title {
    background: #f0f4ff;
    font-size: 16px;
    padding: 4px 8px;
  }
  .el-row {
    padding: 4px;
  }
  .col-left {
    text-align: right;
  }
  .col-right {
  }
}

:deep .el-select {
  width: 100%;
}
:deep .el-date-editor {
  width: 100%;
}
</style>
